package com.example.config;

import java.util.concurrent.CountDownLatch;

/**
 * @program: springboot_course
 * @description:
 * @author: ChenZhiXiang
 * @create: 2019-08-20 19:07
 **/
public class ThreadProvider extends Thread {

    CountDownLatch countDownLatch = null;

    String threadName = null;

    public ThreadProvider(CountDownLatch countDownLatch, String threadName) {
        this.countDownLatch = countDownLatch;
        this.threadName = threadName;
    }

    @Override
    public void run() {
        try {
            Thread.currentThread().setName(threadName);
            System.out.println("threadName:"+threadName);
        }finally {
            if (null != countDownLatch){
                countDownLatch.countDown();
            }
        }

    }
}
